package com.bamanker.cloudsys.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author bamanker
 */
@RestController
@RefreshScope
@RequiredArgsConstructor
@Tag(name = "服务提供者")
public class BizController {

    @Value("${abc.param:000}")
    private String param;

    @Value("${server.port}")
    private String port;

    @GetMapping("/info")
    @Operation(summary = "测试接口1")
    public Map<String, String> getInfo(
            @RequestParam("key") String key) {
        HashMap<String, String> map = new HashMap<>();
        map.put(key, "bbbb");
        map.put("password", "123456");
        map.put("port", port);
        return map;
    }

    @GetMapping("/get")
    @Operation(summary = "测试接口2")
    public String get() {
        return param;
    }

    @GetMapping(value = "/echo/{string}")
    @Operation(summary = "测试接口3")
    public String echo(@PathVariable String string) {
        return "Hello Nacos Discovery " + string;
    }
}
